<?php

namespace app\user\controller;

use app\common\model\Users;
use think\Controller;
use think\Request;

class Base extends Controller
{

    public function initialize()
    {
        //判断是否登陆
        if ( !session('?user') ){
            $this->redirect(url('user/account/login'));
        }

		$user = Users::where('id', session('user.id'))->find();
		unset($user['password']);

	    if ( $user['status'] != 1 ) error('账户已禁用');

		$this->user = $user;

//		halt($user);

		$this->assign('user', $user);
    }

    /** 生成二维码 */
    public function qrcode($url)
    {
        if ( !$url ) return false;
        $code = new \dh2y\qrcode\QRcode();
        $code_path = $code->png($url)->getPath();
        $this->redirect($code_path);
        return $code_path;
    }

}
